<template>
	<view class="cash-out-page">
		
		<view class="cash-list">
				
				<view class="item" 
				:class="{'pending':item.status==1,'success':item.status==2,'denied':item.status==3}" 
				v-for="item in cash_out">
					<view class='money'>
						金额:{{item.amount}}￥
					</view>
					<view class='status'>
						{{item.status_text}}
					</view>
					<view class='date'>
						{{item.created_at}}
					</view>
				</view>
				<view class="nothing" v-if="cash_out.length==0">
					当前没有提现记录
				</view>
			
		</view>
		
		<view class="bottom-button" >
			<view class='cash-text' >当前可提现金额：<text>{{balance}}￥</text></view>
			<view class="cash-out">
				<u-button @click="goto_cashout" type="primary">提现</u-button>
				<!-- <u-picker :show="cashout_show" :columns="cash_arr" @confirm="do_cashout"></u-picker> -->
			</view>
			
		</view>
	</view>
</template>

<script>
	const appInstance = getApp();
	export default{
		
		data() {
			return {
				cash_out:[],
				cashout_show:0,
				cash_arr:[5,10,20,50,100,200,500,1000,2000,5000],
				balance:'',
			}
		},
		onLoad(options) {
			var that = this;
			var host = appInstance.globalData.api_host.split('/app')[0];
			this.cover_bg = appInstance.globalData.customer_bg_img;
			appInstance.globalData.checkUserStatus();
			this.init(options);
		},
		onPullDownRefresh() {
			this.init();
			setTimeout(function () {
			    uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			
			init:function(){
				
				this.get_list();
				this.my_balance();
			},
			
			get_list: function() {
				var t = this;
				var url = '&r=balance.cash_log';
			
				appInstance.globalData.request(url, {}, 'GET', res => {
					t.cash_out = res.data;
				});
			},
			my_balance:function(){
				var t = this;
				var url = '&r=balance.index';
							
				appInstance.globalData.request(url, {
				}, 'GET', function(res) {
					t.balance = res.data.credit.credit2.value;
				});
			},
			
			/**
			 * 跳转用戶提现
			 */
			goto_cashout:function(){
				
				uni.navigateTo({
					url:'/sm_shop/pages/distributor/cash-out-go'
				})
				
			}
		}
		
	}
</script>

<style lang="less">
	@import './distributor.less';
</style>
